/**
 * 
 */
package com.gmail.blackdog1987.carcare.activity;

import java.util.Timer;
import java.util.TimerTask;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

import com.gmail.blackdog1987.carcare.BaseActivity;
import com.gmail.blackdog1987.carcare.R;

/**
 * @author wdy
 *
 */
public class WelcomeActivity extends BaseActivity{
	private Context mContext;
	private static final String TAG = WelcomeActivity.class.getSimpleName();
	
	int count = 5;
	private TimerTask timerTask;
	private Timer timer;

	private Handler mMsgHandler = new Handler(){
		@Override
		public void handleMessage(Message msg) {
			switch (msg.what) {
			case 1:
				if(timer!=null){
					timer.cancel();
					timer = null;
				}
				startActivity(new Intent(WelcomeActivity.this, LaunchActivity.class));
				finish();
				overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out);
				break;
			default:
				break;
			}
		};
	};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_welcome);
		mContext = this;
		initViews();
		reg();
		
		timer = new Timer();
		timerTask = new TimerTask() {
			@Override
			public void run() {
				mMsgHandler.sendEmptyMessage(1);
			}
		};
		
		timer.schedule(timerTask, 3000, 5000);
		
	}

}
